

import java.util.Arrays;
import javaOMC.JavaOMCAPI;

//import javax.swing.*;

public class TestCommand
{
	public static void main(String[] args)
	{
		JavaOMCAPI omc;
		omc=new JavaOMCAPI();
		try
		{
			omc.getStandardLibrary();
			
			System.out.println(omc.cd());
			omc.loadFile("../test/test1.mo");
			omc.loadModel("Modelica");
			System.out.println(omc.getClassNamesList());
			System.out.println(omc.getClassNames("test"));
			System.out.println(omc.getClassRestriction("test"));
			System.out.println(omc.isPackage("test"));
			System.out.println(omc.isPackage("test.test2.mymodel"));
			System.out.println(omc.getElementsInfo("Modelica.Electrical.Analog.Basic.Resistor"));
			System.out.println(omc.getClassInformation("Modelica.Electrical.Analog.Basic.Resistor"));
			System.out.println(omc.getIconAnnotation("Modelica.Electrical.Analog.Basic.Resistor"));
			System.out.println(omc.getDiagramAnnotation("Modelica.Electrical.Analog.Basic.Resistor"));
			System.out.println(omc.getDocumentationAnnotation("Modelica.Electrical.Analog.Basic.Resistor"));
			System.out.println(omc.createModel("myModel"));
			System.out.println(omc.getClassNamesList());
			System.out.println(omc.save("myModel"));
			omc.setSourceFile("myModel", "/home/pauljoseph/Projects/06_OMCAndCorba/javaOMC/mymodel.mo");
			omc.save("myModel");
			omc.sendExpression("package test end test;");
			omc.newModel("newModel", "test");
			omc.getClassNames("test");
			omc.save("test.newModel");
			omc.setSourceFile("test.newModel", "/home/pauljoseph/Projects/06_OMCAndCorba/javaOMC/newmodel.mo");
			omc.setSourceFile("test", "/home/pauljoseph/Projects/06_OMCAndCorba/javaOMC/newmodel.mo");
			omc.save("test");
			omc.sendExpression("package test package test2 end test2; end test;");
			omc.getClassNamesList();
			omc.deleteClass("test");
			omc.getClassNamesList();
			omc.sendExpression("package test package test2 end test2; package test3 end test3; end test;");
			omc.getClassNamesList();
			omc.getClassNamesList("test");
			omc.getClassNamesList();
			//omc.renameClass("test","newTest");
			//omc.getClassNamesList();
			omc.sendExpression("package test model myModel end myModel; end test;");
			omc.list("test");
			omc.setClassComment("test.myModel","this is a comment");
			omc.list("test");
			omc.sendExpression("model mymodel end mymodel;");
			omc.addClassAnnotation("mymodel", "Icon()");
			omc.sendExpression("package test package test_1 end test_1; package test_2 end test_2; model model_1 end model_1; end test; package test2 end test2;");
			omc.getPackages();
			omc.getPackages("test");
			omc.sendExpression("package test model mymodel Real x; Real y; equation x=y; end mymodel; end test;");
			omc.getClassAttributes("test.mymodel");
			omc.sendExpression("package test model mymodel end mymodel; end test;");
			omc.existClass("test.mymodel");
			omc.existPackage("test");
			omc.existModel("test.mymodel");
			omc.getComponents("Modelica.Electrical.Analog.Basic.Resistor");
			omc.addComponent("r1", "Modelica.Electrical.Analog.Basic.Resistor", "test.mymodel","");
			omc.addComponent("c1", "Modelica.Electrical.Analog.Basic.Capacitor", "test.mymodel","Code(())");
			omc.list("test");
			omc.deleteComponent("c1","test.mymodel");
			omc.list("test");
			omc.updateComponent("r1", "Modelica.Electrical.Analog.Basic.Resistor", "test.mymodel", "Placement()");
			omc.list("test");
			//omc.renameComponent("test.mymodel", "r1", "newr1");
			//omc.list("test");
			//omc.renameComponent("test.mymodel", "newr1", "r1");
			omc.addComponent("c1", "Modelica.Electrical.Analog.Basic.Capacitor", "test.mymodel","Code(())");
			omc.list("test");
			omc.addComponent("c2", "Modelica.Electrical.Analog.Basic.Capacitor", "test.mymodel","");
			omc.list("test");
			omc.sendExpression("package test model mymodel Modelica.Electrical.Analog.Basic.Resistor r1; end mymodel; end test;");
			omc.setComponentProperties("test.mymodel","r1",true, true, true, false, "discrete", "{true,false}", "input");
			omc.list("test");
			omc.sendExpression("package test model mymodel Modelica.Electrical.Analog.Basic.Resistor r1; end mymodel; end test;");
			omc.setComponentComment("test.mymodel", "r1", "comment");
			omc.list("test");
			omc.getComponentAnnotations("Modelica.Electrical.Analog.Basic.Resistor");
			omc.getNthComponentAnnotation("test.mymodel","1");
			System.out.println(omc.getNthComponentModification("test.mymodel", "1"));
			omc.setComponentModifierValue("test.mymodel","r1","Code(=2)");
			omc.list("test");
			omc.setComponentModifierValue("test.mymodel","r1.start","Code(=2)");
			omc.list("test");
			omc.getComponentModifierValue("test.mymodel","r1");
			System.out.println(Arrays.toString(omc.getComponentModifierNames("test.mymodel", "r1")));
			omc.getNthComponentModification("test.mymodel", "1");
			omc.getConnectionCount("Modelica.Electrical.Analog.Basic.Resistor");
			System.out.println(omc.checkModel("Modelica.Electrical.Analog.Basic.Resistor"));
			omc.addConnection("r1.p", "c1.n", "test.mymodel", "");
			omc.list("test");
			omc.getConnectionCount("test.mymodel");
			omc.setConnectionComment("test.mymodel", "r1.p", "c1.n", "comment");
			omc.list("test");
			System.out.println(Arrays.toString(omc.getNthConnection("test.mymodel","1")));
			omc.deleteConnection("r1.p","c1.n","test.mymodel");
			omc.list("test");
			omc.addConnection("r1.p", "c1.n", "test.mymodel", "");
			omc.updateConnection("r1.p", "c1.n", "test.mymodel", "Line()");
			omc.list("test");
			omc.getNthConnectionAnnotation("test.mymodel", "1");
			omc.clear();
			omc.sendExpression("package test model mymodel parameter Real p1=2; parameter Real p2; end mymodel; end test;");
			System.out.println(Arrays.toString(omc.getParameterNames("test.mymodel")));
			//omc.setParameterValue("test.mymodel", "p1", "2");
			//omc.list("test");
			omc.getParameterValue("test.mymodel","p1");
			System.out.println(omc.getInheritanceCount("Modelica.Electrical.Analog.Basic.Resistor"));
			System.out.println(omc.getNthInheritedClass("Modelica.Electrical.Analog.Basic.Resistor","1"));
		}
		catch(Exception ex)
		{
		System.out.println(
			  "\nError...\n"+
			  ex.getMessage());
		}
		
	}
}
